// 测试手机号脱敏功能
console.log('=== 测试手机号脱敏功能 ===');

// 测试手机号脱敏逻辑
function testPhoneMasking() {
  const testPhones = [
    '13800138000',
    '13912345678',
    '18600000000',
    '18999999999',
    '12345678901'
  ];

  console.log('\n手机号脱敏测试:');
  testPhones.forEach(phone => {
    const maskedPhone = '****' + phone.slice(-4);
    console.log(`原始: ${phone} -> 脱敏: ${maskedPhone}`);
  });

  // 测试边界情况
  console.log('\n边界情况测试:');
  const edgeCases = [
    '1234',      // 4位
    '123',       // 3位
    '12',        // 2位
    '1',         // 1位
    '',          // 空字符串
    null,        // null
    undefined    // undefined
  ];

  edgeCases.forEach(phone => {
    if (phone && phone.length >= 4) {
      const maskedPhone = '****' + phone.slice(-4);
      console.log(`原始: ${phone} -> 脱敏: ${maskedPhone}`);
    } else {
      console.log(`原始: ${phone} -> 脱敏: 不满足条件`);
    }
  });

  // 测试WXML模板逻辑
  console.log('\nWXML模板逻辑测试:');
  const userInfo = { phone: '13800138000' };
  const templateResult = userInfo.phone ? '****' + userInfo.phone.slice(-4) : '********';
  console.log(`模板结果: ${templateResult}`);

  const userInfoNoPhone = { phone: '' };
  const templateResultNoPhone = userInfoNoPhone.phone ? '****' + userInfoNoPhone.phone.slice(-4) : '********';
  console.log(`无手机号模板结果: ${templateResultNoPhone}`);
}

// 运行测试
testPhoneMasking(); 